// pages/index/index.js
var movieUrl = "https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items";//电影列表
var tvUrl = "https://m.douban.com/rexxar/api/v2/subject_collection/tv_hot/items";//电视剧列表
var tv_varietyUrl = "https://m.douban.com/rexxar/api/v2/subject_collection/tv_variety_show/items"//综艺列表
Page({
  data: {
    movieCollectionName: "",
    tvCollectionName: "",
    tv_varietyCollectionName: "",
    movieItem: [],
    tvItem: [],
    tv_varietyItem: []
  },
  onClickLeft() {
    wx.navigateBack({
      delta: 1,
    })
  },
  tapSearch(event) {
    wx.navigateTo({
      url: '/pages/appLetWork/work22/search/search?value=' +event.detail,
    })
  },
  onLoad: function (options) {
    var that = this;
    wx.request({
      url: movieUrl,
      success({ data }) {
        //console.log(data)
        that.setData({
          movieCollectionName: data.subject_collection.name,
          movieItem: data.subject_collection_items,
        })
      }
    });
    wx.request({
      url: tvUrl,
      success({ data }) {
        //console.log(data)
        that.setData({
          tvCollectionName: data.subject_collection.name,
          tvItem: data.subject_collection_items
        })
      }
    });

    wx.request({
      url: tv_varietyUrl,
      success({ data }) {
        //console.log(data)
        that.setData({
          tv_varietyCollectionName: data.subject_collection.name,
          tv_varietyItem: data.subject_collection_items
        })
      }
    })
  },

  //每个电影点击事件
  movieItems({ currentTarget }) {
    // console.log(currentTarget.dataset)
    wx.navigateTo({
      url: '/pages/appLetWork/work22/content/content?id=' + currentTarget.dataset.id + "&type=" + currentTarget.dataset.type,
    });
  },
})